
<%@ include file="/html/portlet/ext/myprofile/init.jsp" %>
<%

MyProfile profile = MyProfileLocalServiceUtil.getUserId(userId);

	SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy");
	User selUser = UserLocalServiceUtil.getUserById(userId);
	long p_u_i_d = (selUser != null) ? selUser.getUserId() : 0 ;
	long portrait_id = (selUser != null) ? selUser.getPortraitId(): 0; 
	String profileId = request.getParameter("profileId");

	MyProfile myprofile = MyProfileUtil.fetchByUserId(userId);	
	Contact ct = ContactLocalServiceUtil.getContact(selUser.getContactId());
	
	Date dob = ct.getBirthday();
	Date now = new Date();	
	long diff = now.getTime() - dob.getTime();
	int months = (int) (diff / (1000*60*60*24));		
	int years = (int)(months / 365.25);
	int mnths = months -(years*12);		
	String age = years + " Years";
	
	PortletURL url = renderResponse.createActionURL();
	url.setWindowState(WindowState.NORMAL);
	url.setParameter("struts_action", "/ext/myprofile/add_profile");
	url.setParameter("cmd", "APPROVE");
	
	PortletURL url1 = renderResponse.createActionURL();
	url1.setWindowState(WindowState.NORMAL);
	url1.setParameter("struts_action", "/ext/myprofile/add_profile");
	url1.setParameter("cmd", "EDIT");
	
	
	PortletURL url2 = renderResponse.createActionURL();
	url2.setWindowState(WindowState.NORMAL);
	url2.setParameter("struts_action", "/ext/myprofile/add_profile");
	url2.setParameter("cmd", "PREVIEW");

%>
<script type="text/javascript">
	function submit(url) {
		var frm = document.<portlet:namespace/>fm;
		submitForm(frm,url);
	}
</script>

<script type="text/javascript">
jQuery(document).ready(function(){
	
	jQuery(".accordion h3:first").addClass("active");
	jQuery(".accordion p:not(:first)").hide();

	jQuery(".accordion h3").click(function(){
		jQuery(this).next("p").slideToggle("slow");
		
		jQuery(this).toggleClass("active");
		jQuery(this).siblings("h3").removeClass("active");
	});

});
</script>
<style type="text/css">
body {
	
	font: 75%/120% Arial, Helvetica, sans-serif;
}
.accordion {
	
	border-bottom: solid 1px #c4c4c4;
}
.accordion h3 {
	background: #e9e7e7 url(/html/accordion/images/arrow-square.gif) no-repeat right -51px;
	padding: 7px 15px;	
	font: bold 120%/100% Arial, Helvetica, sans-serif;
	border: solid 1px #c4c4c4;
	border-bottom: none;
	cursor: pointer;
	color:Brown
}
.accordion h3:hover {
	background-color: #e3e2e2;
}
.accordion h3.active {
	background-position: right 5px;
}
.accordion p {
	background: #f7f7f7;
	margin: 0;
	padding: 10px 15px 20px;
	border-left: solid 1px #c4c4c4;
	border-right: solid 1px #c4c4c4;
}
</style>
<fieldset class="block-labels col">
	<div>
		My Photo: 
		<img alt="<%= selUser.getFullName() %>" class="avatar" src="<%= themeDisplay.getPathImage() %>/user_<%= selUser.isFemale() ? "female" : "male" %>_portrait?img_id=<%= selUser.getPortraitId() %>&t=<%= ImageServletTokenUtil.getToken(selUser.getPortraitId()) %>" />
	</div>
</fieldset>
		<div class="accordion">
		<h3>Name Details </h3>
		<p>First Name: <%=ct.getFirstName()%> <br/><br/>
		   Last Name: <%=ct.getLastName()%> <br/><br/>
		   Email Address: <%=selUser.getEmailAddress()%> <br/><br/>
		  <%if(selUser.getComments().equals("student")){%>
			Standard:
			<%}
			else if(selUser.getComments().equals("collStudent")){%>
			Degree:
			<%}else if(selUser.getComments().equals("")){%>			
			<%}else {%>
			Job Title:
			<%}%>
		<%if(!(selUser.getComments().equals(""))){
		CollStudent ctt = CollStudentUtil.fetchByMyProfileUserId(userId);
		%>
		 <%=(ct.getJobTitle().equals("")||ct.getJobTitle().equals("Others"))?ctt.getOthers():ct.getJobTitle()%> <br/><br/>
		 <%}%>
		   Age: <%=age%>		
		</p>
		</div>
<form name="<portlet:namespace/>fm"  method="POST">
	
	<%if(profile==null){ if (group.isCommunity() || (!group.isCommunity() && (theme1.getUserId()==grUserId)) ) {	%>
	<a href="javascript:void 0" onClick="submit('<%=url.toString()%>');">Update More &raquo;</a>
	<% } } %>
	<%if(profile!=null){ %>
	<% url2.setParameter("userId", String.valueOf(userId)); %>	
	<a href="javascript:void 0" onClick="submit('<%=url2.toString()%>');">Read More &raquo;</a>
   	<%} %>	
</form>